package com.bluefish.bltuan.action;

import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;

import com.bluefish.bltuan.module.shop.TuanGou;
import com.bluefish.bltuan.service.ShopService;

public class ShopAction extends OpenAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2291717716061441111L;

	private TuanGou tuan;
	
	private ShopService shopService;
	
	@Override
	public HttpHeaders show() {
		String nick = this.getId();
		if(nick !=null && nick.trim().length() > 0){
			this.tuan = this.shopService.getPublishedTuanByNick(nick);
			if(this.tuan != null && !this.tuan.isFuture()){
				return new DefaultHttpHeaders(SHOW).disableCaching();
			}
		}
		return new DefaultHttpHeaders(NOT_FOUND).disableCaching();
	}
	
	public void setShopService(ShopService shopService) {
		this.shopService = shopService;
	}
	
	public TuanGou getTuan() {
		return tuan;
	}
}
